Skip to content

Keep Reader saved posts in the WordPress.com account - #26372

Merged
crazytonyli merged 15 commits into
trunkfrom
jkmassel/reader-saved-posts-account
Nov 20, 2026
Merged

crazytonyli merged 15 commits into
trunkfrom
jkmassel/reader-saved-posts-account

Conversation

@jkmassel

@jkmassel jkmassel commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor

Description

Reader's saved posts now live in the user's WordPress.com account instead of only on one device, so they sync between devices and survive a reinstall. Posts already saved on the device move to the account on first launch.

Uses wordpress-rs 0.11, the first release with ReaderSavedService (Automattic/wordpress-rs#1720 and #1734). Trunk already has it (0.11.1, from #26420), so this PR doesn't change the package.

Warning

If you ran an earlier build of this PR, delete the app before installing this one. wordpress-rs 0.11.0 folded the unreleased account and Reader migrations into one, so a cache that ran a PR build's migrations has tables this release doesn't expect. Released versions never had these migrations, so users aren't affected.

How it works

  • The account is the source of truth. wordpress-rs's ReaderSavedService saves and unsaves through the WordPress.com API and keeps the saved list in WordPressApiCache, under the account. The list shows from disk after a relaunch, including offline.
  • Saves and unsaves work offline. A tap is kept in the cache straight away, so the bookmark and the Saved list show it at once, and it survives a relaunch. wordpress-rs sends taps to the server one at a time, in order. One that can't be sent yet goes with the next sync, which the app starts at launch, when it comes to the foreground and when the device comes back online. A save the server refuses is undone. A tap past the account's 1,000-save cap is undone too, and the notice says the account is at its limit.
  • One service per account. ReaderSavedPostsStore holds it and replaces it when the account changes. It sends one request at a time, and a second instance would send alongside it.
  • New Saved screen. A SwiftUI list fed by the cached saved list, with pull to refresh, paging, swipe or long-press to remove, and empty and error states. Tapping a post opens the usual post screen; a page saved by URL opens in the in-app web view.
  • Each saved row shows the site icon, tags and comment count, from Give saved posts their site icon, tags and comment count Automattic/wordpress-rs#1734. The saved list already sends them, so there are no extra requests.
    • The icon is the site's icon, or an RSS feed's image. Feeds that publish no image show none.
    • Up to three tags are shown.
    • A comment count of 0 isn't shown, because the server sends 0 for RSS posts and pages saved by URL, which can't have comments.
    • The image is the one the post's Reader card shows (displayImageUrl from Give saved posts their site icon, tags and comment count Automattic/wordpress-rs#1734): the featured image, or else the image the server picks from the post. A save sends the card's image too.
    • The icon loads like the avatar on Reader post cards: the same URL (makeReaderSiteIconURL, including the built-in icons for sites without one) at the same size. Both are part of the image cache's key, so an icon a stream has loaded shows in Saved straight away. The row reads the memory cache while drawing rather than after its first frame.
  • A post saved just now shows in full straight away. The bookmark sends the post's details with the save (saveWithDetails, from Give saved posts their site icon, tags and comment count Automattic/wordpress-rs#1734), so Saved doesn't show an empty row until the next refresh. They only fill in what the cache doesn't have, and the saved list's copy replaces them on the next refresh.
  • Bookmark icons on post cards and the post screen show the account's status. While the account doesn't know a post yet (before the first refresh), they fall back to the Core Data flag.

Moving existing saves to the account

  • On the first launch with an account, the posts with isSavedForLater are sent to it in one import, in the order the old Saved screen showed them (sortRank, newest first). The app records the import per account in UserDefaults and doesn't repeat it. wordpress-rs imports whenever it's asked, so a repeat would bring back posts unsaved since. Signing out clears the record.
  • If the import fails (for example offline), it's tried again on the next launch. Saving a post twice does nothing, so a retry is safe.
  • Saves past the account's 1,000-save cap stay saved and show in the list. wordpress-rs sends them once there's room, trying the oldest once per sync. Saves the server refuses for another reason are undone.
  • While any saves wait for room, Saved shows a banner at the top: “Saved posts limit reached. 1 post is saved only on this device. Your account keeps up to 1,000 saved posts. Remove some to make room for it.” The count is wordpress-rs's savesWaitingForRoom(), read again whenever the list reloads, so the banner goes away once the saves are sent. The same applies to a save made offline that the server refuses for the cap when it syncs.
  • The Core Data flags are left in place, as a way back if this has to be rolled back. Nothing writes them any more. A later release can delete them.
  • A new Tracks event, reader_saved_posts_account_import, records how the import ended: counts of local, imported, refused, pending, waiting-for-room and unsaveable saves, or an error kind. It holds no URLs or titles.

Other changes

  • Signing out deletes everything for the account from the cache (removeWordpressComAccount).
  • Without a WordPress.com account (only a self-hosted site), the import/export row in App Settings is hidden, because saving needs the account. The Reader itself shows its "Sign in" screen in that case, so Saved and the bookmark buttons can't be reached; they're hidden there too as a fallback.
  • JSON import and export use the account.
    • Export loads every page of the saved list first, so it isn't limited to what the Saved screen has loaded. The saved list sends 10 posts a page, so an account at the 1,000-save cap is 100 pages; the export stops only after 250. Each export goes in its own temp folder, and includes each post's tags.
    • Import skips posts the account already has (they count as skipped, as the settings footer says). It sends the rest in one import, the same call as the first-launch import, with the file's title, excerpt, image and site so the list shows them straight away. Then it refreshes the saved list for the posts' details. A save that can't be sent yet, or that waits for room under the cap, still counts as imported, because it's in the list and a later sync sends it.
  • A page saved by URL can be imported back from an export. The export writes it with no site, feed or post ID, and the import saves any entry without a site or feed by its URL, whatever its post ID. Files exported by earlier builds of this PR wrote the server's own ID for such a page, and still import.
  • Opening a post from Saved uses the copy on the device when Core Data has it with its content (ReaderSavedPostsViewController.storedPost(for:in:)), as the old Saved stream did. It opens straight away and works offline. Other posts are still fetched by their IDs first.
  • Removed: the local-only save toggle (toggleSavedForLaterForPost:), the old Saved stream as a destination, and the "saved posts don't sync" copy.
  • wordpress-rs now has its own ReaderPost type, so the three files that import both it and WordPressData name the Core Data class WordPressData.ReaderPost.

Known gaps

  • An imported save that can't be sent yet (offline, or waiting for room under the cap) has no save date, so it's listed at the bottom of Saved until the server sends its date.
  • Pages saved by URL sort above posts after an import, both at first launch and from a file. wordpress-rs saves them one at a time after the bulk request, so they get the newest save dates. That needs a fix in wordpress-rs.
  • ReaderContentType.saved and its branches in ReaderStreamViewController are now unused. Removing them means reworking that screen's content types, so it's left for a follow-up.

Screenshots

The saved posts are placeholder data, injected with a temporary patch for these screenshots.

Saved (light) Saved (dark) Swipe to remove
Saved screen listing six placeholder posts, including a page saved by URL shown as example.com The Saved screen in dark mode A saved post swiped to show the Remove action
No saved posts First save
Saved screen empty state: No saved posts First-save alert saying saved posts sync across devices signed in to the same WordPress.com account
Saved posts settings JSON import result Signed out, self-hosted only: App Settings has no Saved Posts row
Saved Posts settings with Import and Export Import Complete alert with imported, skipped and failed counts App Settings Other section without a Saved Posts row
Site icon, tags and comment count (real account, public posts) Saved just now, before any refresh
Saved rows: The Verge RSS post with the feed's image as its icon and no comment count; a WordPress.com Blog post with its site icon, three tags and 8 comments A post bookmarked in Discover a moment earlier, already showing its site name, title, excerpt, tags and 8 comments in Saved
Saved offline, before the sync (real account, public posts)
Saved screen with a post saved while offline at the top, shown in full with tags and comment count
Import of the app's own export, after removing a page saved by URL (real account) Saves waiting for room under the cap (real account)
Import Complete: 1 imported, 999 skipped, 0 failed Saved with a banner: Saved posts limit reached. 1 post is saved only on this device. Your account keeps up to 1,000 saved posts. Remove some to make room for it.
Save with the account at its 1,000-save cap JSON import with the account at its cap
Notice: Could not save post for later. You’ve reached the limit of 1,000 saved posts. Remove some to save more. Import Complete: 1 imported, 0 skipped, 0 failed

What I ran

  • I built this change and ran the affected tests locally

After rebasing on trunk 1f4ba93afe (which includes #26420), this branch (7224f6cff1), wordpress-rs 0.11.1, a new iPhone 18 Pro simulator (iOS 27.2):

Suites Result
ReaderSavedPostsSyncTests, ReaderSavedPostsStoreTests, ReaderSavedPostsViewModelTests, ReaderSavedPostsExporterTests, ReaderSidebarSavedTests, ReaderPostToolbarBookmarkTests Test run with 72 tests in 6 suites passed
ReaderDetailCoordinatorTests Executed 15 tests, with 0 failures
Jetpack scheme build ** BUILD SUCCEEDED **
ReaderSavedPostsCacheTests (before the rebase, 2b3fe1d74d, 0.11.0) Test run with 1 test in 1 suite passed
ReaderSavedPostsStoreTests, 15 runs in a row (before the rebase, a9de039dcf) 15 of 15 passed with no issues (before the store took its own notification center, the foreground and back-online tests recorded failures when run in parallel)

Earlier, on the PR build of wordpress-rs: ReaderDetailToolbarTests, ReaderPostToolbarBookmarkTests and ReaderNotificationsBellTests passed, as did AccountServiceTests, ReaderPresenterTests and ReaderStreamViewControllerTests (Executed 24 tests, with 0 failures). They weren't rerun on 0.11.0, which changes nothing they use.

Regression tests that fail without their fix: signing out while a bookmark is on screen doesn't bring the account back (noSessionWhileSigningOut), export includes pages that weren't loaded (exportLoadsEveryPage), and export includes every save of an account at the cap (exportLoadsAFullAccount: with the old 50-page limit it fails with Expectation failed: posts.count == 1000).

Testing instructions

Checked on the simulator with a real WordPress.com account. Its saved list was the same before and after every check. Items marked (7224f6cff1) were checked on this branch's head, on wordpress-rs 0.11.1; items marked (0.11.0) on the build before the rebase; the rest on the PR build of wordpress-rs, and the app code they use didn't change since except where noted.

  • (7224f6cff1) Tony's steps for a page saved by URL. The account was at its cap: 999 pages saved by URL and one post. Export wrote all 1,000 saves (272 KB); the page's entry has no IDs. After removing the page in Saved (server: 999), importing the file from Files reported “1 imported, 999 skipped, 0 failed”, the page was back at the top of Saved, and the server's saved keys matched the snapshot taken before the check. Before this fix, the same steps gave “0 imported, 2 skipped, 1 failed” and “Post not found”.

  • (7224f6cff1) Export at the cap. The first export on this build wrote only 500 of the 1,000 saves, which found the 10-a-page bug fixed in 7224f6cff1; after the fix it wrote 1,000.

  • (7224f6cff1) Banner for saves waiting for room. With the account at its cap, importing a file with one new post reported “1 imported”; the cache had it waiting_for_room, the server didn't, and Saved showed the banner with “1 post”. Removing a save in Saved made room: the waiting save reached the server within 10 seconds and the banner went away. The account was then put back as it was. The waiting post itself is listed last, because an imported save has no date (see Known gaps).

  • (7224f6cff1) Opening a saved post from the device. A post saved from Discover (opened once, so it's in Core Data) opens from Saved with its title, author and image already shown after 1 second. Relaunched with -wpcom-api-base-url http://127.0.0.1:9, so every WordPressKit request fails, it still opens from Saved with its full content. The same post opened by its IDs through a jpdebug:///read/blogs/…/posts/… link shows “Error Loading Post”, which is what Saved showed before this change. The test save was removed afterwards. The offline save at the cap that ends up waiting for room (Tony's issue 2) wasn't reproduced on the simulator; the import above puts a save in the same waiting_for_room state.

  • (0.11.0) A fresh install loads Saved from the 0.11.0 cache, with the account's saves.

  • (0.11.0) Saving with the account at its 1,000-save cap. The test account was at the cap. Tapping a Discover post's bookmark shows “Could not save post for later. You've reached the limit of 1,000 saved posts. Remove some to save more.” The bookmark stays empty, and the server's saved keys are unchanged.

  • (0.11.0) JSON import with the account at its cap. Importing a file with one new post reports "1 imported, 0 skipped, 0 failed". The cache has the post saved, listed and waiting_for_room, and the server's saved keys are unchanged. The app was deleted afterwards, so the waiting save was never sent.

  • Upgrade with local saves (PR build). Install trunk, save two posts, then install this build over it. The app log shows imported 2, refused 0 and one reader_saved_posts_account_import event; Saved shows both posts in the old screen's order without a pull to refresh; the server's saved keys include them. A second launch doesn't import again. On 0.11.0 the app, not wordpress-rs, remembers the import; that's covered by importRunsOnce, concurrentStartsImportOnce and removeAccountForgetsTheImport, not rechecked on the simulator.

  • Save and unsave from a stream. The bookmark fills in, the post appears at the top of Saved, and the post screen's toolbar shows it as saved. Swiping to remove takes it off the list and the stream's bookmark empties.

  • Offline relaunch. With the app's WordPress.com requests blocked, Saved still shows the list from disk.

  • Save offline, then sync on coming to the foreground. With the saved posts requests refused by a local proxy (a temporary, uncommitted hook in a Jetpack build), saving a Discover post fills its bookmark and puts it at the top of Saved in full, while the server's saved keys stay unchanged. Back online with the app left open, nothing is sent for 30 seconds; sending the app to the background and back sends the save within 2 seconds. Unsaving both test posts online put the server's keys back exactly as they were. The "back online" trigger wasn't exercised on a real network change, because the simulator shares the Mac's network; it's covered by reachabilitySyncs.

  • Sign out with a Reader stream on screen. Every Reader table and wordpress_com_accounts in the cache has 0 rows afterwards (read with sqlite3), and signing back in brings the list back.

  • A feed item and a page saved by URL both open from Saved; the URL opens in the in-app web view.

  • Signed out with only a self-hosted site (a local WordPress Playground site): App Settings has no Saved Posts row. The Reader tab shows its "Sign in with a WordPress.com account" screen, and a deep link to a post lands there too, so the sidebar and bookmark hiding is only a fallback (covered by ReaderSidebarSavedTests and ReaderPostToolbarBookmarkTests).

  • JSON import and export (PR build; the import now goes through importSaves, checked at the cap above). Export writes every saved post to its own temp folder. On this build, importing a file with an already-saved post, a new public post and a page saved by URL: the first run reported "1 imported, 2 skipped, 0 failed" and found a bug, a page saved by URL wasn't saved. The fix then covered only a page saved moments before the export; a page the server had already sent still failed, which Tony found and be66c4a7fa fixes (checked above). After the first fix, the page is imported and shows at the top of Saved straight away, with no pull to refresh. The test saves and the file were removed afterwards, and the server's saved keys match what they were before.

  • Site icon, tags and comment count. With a WordPress.com Blog post and a Verge RSS post saved for the check (and removed afterwards), the WordPress.com post shows its site icon, #chatgpt #claude #mcp and "8 comments". The Verge post shows the feed's image and no comment count. The older WordPress.com save shows its site icon and tag.

  • Save from Discover, then open Saved straight away. The new row already shows its site name, title, excerpt, tags and comment count; after the refresh it has the server's tags and the saved date. The test save was removed afterwards.

  • A post with no featured image (“Caption Demo”, whose author set none) shows the same image in Saved as on its Reader card.

  • Paging in the Saved list: not checked in the app, because the test account has only one saved post. Covered by ReaderSavedPostsViewModelTests and the export paging test.

@jkmassel jkmassel added the Reader label Nov 9, 2026
@jkmassel jkmassel self-assigned this Nov 9, 2026
@jkmassel jkmassel added this to the 27.5 milestone Nov 9, 2026
@dangermattic

dangermattic commented Nov 9, 2026 •

Copy link
Copy Markdown
Collaborator
2 Warnings
⚠️ This PR is larger than 500 lines of changes. Please consider splitting it into smaller PRs for easier and faster reviews.
⚠️ This PR is assigned to the milestone 27.5. This milestone is due in less than 4 days.
Please make sure to get it merged by then or assign it to a milestone with a later deadline.

Generated by 🚫 Danger

@wpmobilebot

wpmobilebot commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

🤖 Build Failure Analysis

This build has failures. Claude has analyzed them - check the build annotations for details.

jkmassel added a commit to Automattic/wordpress-rs that referenced this pull request Nov 12, 2026
Every build of a PR uploaded its xcframework to `pr-builds/<PR>`,
replacing the previous build's file. CloudFront kept serving the cached
copy, so an app pinned to the new `pr-build/<PR>` commit downloaded an
older xcframework and failed SwiftPM's checksum check. WordPress-iOS CI
failed this way on wordpress-mobile/WordPress-iOS#26372, and a local build did too.

Each build now goes to `pr-builds/<PR>/<build number>`, as trunk builds
already go to `trunk-builds/<commit>`. The build number rather than the
commit, so rebuilding the same commit doesn't reuse a path either.
jkmassel added a commit to Automattic/wordpress-rs that referenced this pull request Nov 12, 2026
Every build of a PR uploaded its xcframework to `pr-builds/<PR>`,
replacing the previous build's file. CloudFront kept serving the cached
copy, so an app pinned to the new `pr-build/<PR>` commit downloaded an
older xcframework and failed SwiftPM's checksum check. WordPress-iOS CI
failed this way on wordpress-mobile/WordPress-iOS#26372, and a local build did too.

Each build now goes to `pr-builds/<PR>/<build number>`, as trunk builds
already go to `trunk-builds/<commit>`. The build number rather than the
commit, so rebuilding the same commit doesn't reuse a path either.
@jkmassel
jkmassel force-pushed the jkmassel/reader-saved-posts-account branch from d991415 to 745469e Compare November 12, 2026 20:01
@jkmassel
jkmassel marked this pull request as ready for review November 12, 2026 20:01
@jkmassel
jkmassel requested a review from crazytonyli November 12, 2026 20:01
jkmassel added a commit to Automattic/wordpress-rs that referenced this pull request Nov 12, 2026
Every build of a PR uploaded its xcframework to `pr-builds/<PR>`,
replacing the previous build's file. CloudFront kept serving the cached
copy, so an app pinned to the new `pr-build/<PR>` commit downloaded an
older xcframework and failed SwiftPM's checksum check. WordPress-iOS CI
failed this way on wordpress-mobile/WordPress-iOS#26372, and a local build did too.

Each build now goes to `pr-builds/<PR>/<build number>`, as trunk builds
already go to `trunk-builds/<commit>`. The build number rather than the
commit, so rebuilding the same commit doesn't reuse a path either.
@crazytonyli

Copy link
Copy Markdown
Contributor

Rebase this PR, since it contains the same changes in #26404?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you think the “Export” feature can be removed now? I believe it’s built because the saved posts were local only. Now that they are on the server too, I think the “Export” feature is now redundant? /cc @twstokes

If export is removed, we can remove import too, which I think should simplify the implementation.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's nice for users to be able to take their data out of the system? That said, this might make more sense as a web feature than a mobile one?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That said, this might make more sense as a web feature than a mobile one?

I agree.

From the original PR #25509:

Saved Reader posts are local-only and don't sync across devices. This adds the ability to import and export them as a JSON file, so users can back up their saved posts or transfer them between devices/apps.

It's now synced with API.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

WDYT about removing it from the app once it's built for the web?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AI found an issue with importing exported file. It probably should be fixed if the Export feature is kept:

A page saved by URL is not restored when importing the app's own export

Steps:

  1. Sign in with a WordPress.com account that has a page saved by URL in Saved.
  2. Open Reader → Saved and let the list load.
  3. Open the Saved Posts screen and tap Export Saved Posts. Save the file.
  4. In Saved, swipe the page saved by URL and tap Remove.
  5. Open the Saved Posts screen again, tap Import Saved Posts, and pick the file from step 3.

Expected: The alert counts the page as imported, and the page is back in Saved and on wordpress.com/read/saved.

Actual: The alert says "0 imported, 2 skipped, 1 failed". The page does not come back, in the app or on the account. The app log has:

[org.wordpress:wp_mobile::service::reader_saved] The server refused a saved post change: Post not found.

How often: 2 of 2 tries, on two builds of this PR (745469e and a9de039).

Page saved by URL in Saved Import result After import
Saved list with the page saved by URL at the top Import Complete alert: 0 imported, 2 skipped, 1 failed Saved list after import, without the page saved by URL

The exported entry for that page:

{
  "author": "",
  "isFeed": true,
  "postID": 70576,
  "siteName": "",
  "siteURL": "",
  "summary": "A disposable URL-only page for the round 2 export and import check.",
  "tags": [],
  "title": "Saved Posts review page r2",
  "url": "https://example.com/?saved-posts-review=26372-r2"
}

Note: the page saved by URL in step 1 was created with the saved-posts API ({"url": "https://example.com/?saved-posts-review=26372-r2"}). Steps 2 to 5 were done in the app.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From Claude: We'll keep export/import for this release, and remove it from the app once the web has it. The import bug is fixed in be66c4a. Testing it also found that export wrote only 500 posts for an account at the 1,000-save cap, fixed in 7224f6c.

@jkmassel
jkmassel force-pushed the jkmassel/reader-saved-posts-account branch from a9de039 to 2b3fe1d Compare November 18, 2026 20:36
@jkmassel

Copy link
Copy Markdown
Contributor Author

From Claude: Rebased on trunk (ab8e78d4db), which has #26404. The wordpress-rs bump and the three comment-file changes are gone from this PR, and the commit that pinned the #1743 build dropped out because it was empty. The saved-posts tests pass on the rebased branch.

@jkmassel
jkmassel requested a review from crazytonyli November 18, 2026 20:42
@crazytonyli

Copy link
Copy Markdown
Contributor

There are also these issues, but I don't think they are really that important:

1. A saved post doesn't open offline from Saved, even when it's stored on the device

Saved opens posts by ID (ReaderSavedPostsView.swift#L64-L92), so the post screen always fetches the post first and shows an error if the fetch fails, even with the post in Core Data. The old Saved stream passed the post itself. Online, every open from Saved shows a spinner for 2 to 6 seconds before the content.

  1. Save a post from Reader → Discover.
  2. Open it from Reader → Saved, then go back.
  3. Turn on airplane mode.
  4. Open the same post from Saved.

Expected: the post shows from the device. Actual: an error. Found with a unit test of the detail coordinator; the airplane mode steps have not been run by hand.

2. A post saved offline when the account is at the 1,000-save limit stays saved, with no notice

The description says a tap past the limit "is undone too, and the notice says the account is at its limit". That only happens online. Offline, the tap is queued; when the device reconnects, the server refuses it for the limit, but no tap is waiting, so the post stays saved and listed with no notice. It never reaches the account, so other devices don't see it. A file import counts such saves as "imported" too. ReaderSavedListItem.isWaitingForRoom is there for this, but the row doesn't use it.

  1. With an account that has 1,000 saved posts, turn on airplane mode.
  2. Save a post.
  3. Turn off airplane mode and let the app sync.

Expected: the save is undone, with the limit notice. Actual: it stays saved, with no notice, and isn't on wordpress.com/read/saved. Found with a test using the real wordpress-rs service and scripted server replies; not run with a real account at the limit.

3. An imported page saved by URL doesn't send its title to the server

The import keeps the file's title for the row on this device, but the save request is only {"url": ..., "source": "ios"}. Other devices and a reinstall don't get the title from the file. Saving URL entries with saveUrl(url:pageDetails:) would send it. Found with a test that reads the request; with the app's own export, the export/import issue above happens first.

4. A stale saved list from the server can unsave a post that was just saved

If the server's saved list lags behind a save it already confirmed, the next sync shows the post as not saved and removes it from Saved. This comes from wordpress-rs (Automattic/wordpress-rs#1720), but this PR syncs at launch, on every foreground and on every reconnect, so a lagging list has more chances to land. Found with a test using a scripted stale reply; not seen live.

Saved posts used to live only in Core Data on one device. They now go
through wordpress-rs's ReaderSavedService, which keeps them in the
user's WordPress.com account and caches the saved list in
WordPressApiCache.

- A new SwiftUI Saved screen reads the cached list, with pull to
  refresh, paging, and swipe to remove.
- Saving and unsaving go to the account; bookmark icons read the
  account's status.
- Posts saved on the device are sent to the account once per account,
  in the order the old Saved screen showed them. The Core Data flags
  are left in place.
- Signing out deletes the account's Reader data from the cache.
- Without a WordPress.com account, Saved and the save buttons are
  hidden.
- JSON import and export use the account.

Pins wordpress-rs to the #1729 PR build; it needs a release before
this can merge.
Two exports on the same day wrote to the same file, so one could read
the other's half-written file.
An import counted posts the account already had as imported, although
the settings footer says duplicates are skipped, and the imported posts
only showed in Saved after a pull to refresh.
Moves wordpress-rs to the build of Automattic/wordpress-rs#1734, which reads
them from the saved list. Saved rows show the site icon (or an RSS feed's
image), the first three tags and the number of comments. A count of 0 isn't
shown, because the server sends 0 for posts that can't have comments. The
saved date leaves out the year for this year's saves.

The JSON export now includes each post's tags.

wordpress-rs now has its own `ReaderPost`, so files that import it and
WordPressData name the Core Data class as `WordPressData.ReaderPost`.
Saving a post from a stream now sends its details with the save
(`saveWithDetails`, from Automattic/wordpress-rs#1734), so the Saved list
shows its title, site, excerpt, tags and comment count straight away. Before,
the list showed an empty row until the next refresh brought the post back.

The details come from the Core Data post. They only fill in what the cache
doesn't have, and the saved list's copy replaces them on the next refresh.
The Saved rows asked for the site icon at its full URL with no size, so
they never matched what the Reader's post cards had already loaded: the
image cache's key includes the size. Each row also drew its placeholder
first, because `CachedAsyncImage` only checks the memory cache once its
task runs. So the icon arrived a beat late even for a site whose posts were
on screen a moment earlier.

The rows now build the icon URL with `makeReaderSiteIconURL` and load it at
the post cards' size, and read the memory cache while drawing, so an icon
that's already loaded shows in the first frame. Sites without an icon URL
also get the same built-in icon the cards use.
A post whose author set no featured image had an image on its Reader card
but none in Saved. The card falls back to the image the server picks from
the post (`featured_media`), and Saved only read `featured_image`.

Moves wordpress-rs to the build of Automattic/wordpress-rs#1734 that adds
`displayImageUrl`, picked the way the cards pick it. Saved rows and the
JSON export use it, and a save sends the image the post's card shows.
Automattic/wordpress-rs#1720 now keeps each save and unsave in the cache and sends them from a
queue, one at a time, so they work offline. This pins the build of #1734, which is stacked on it.

- Sync at launch, when the app comes to the foreground, and when the device comes back online, as
  the service asks. `refresh()` on the service is now `sync()`.
- The JSON import saves each post as a tap would, oldest first so the newest ends up at the top.
  The bulk import it used is gone. A save that can't be sent yet still counts as imported.
- Reading a post's status can fail now; it's logged and read as not known.
- The first-launch import's log line and event include the saves still waiting to be sent.
The export writes a page saved by URL without IDs, but its key needs an external identity with a
`0` site and feed. Without them the import reported the page as skipped and didn't save it.
wordpress-rs 0.11.0 (from #26404) is the first release with
`ReaderSavedService`, which this branch used from PR builds.

- `importSaves` replaces `importLocalSaves` and imports whenever it's
  asked, so the app records the launch import per account in
  `UserDefaults`, clears the record on sign-out, and runs one import at a
  time.
- JSON import sends the file's posts in one `importSaves` call, with the
  file's title, excerpt, image and site, rather than one save per post.
- A tap past the account's 1,000-save cap fails with `TooManySaves`, and
  the notice says the account is at its limit. A sync that leaves saves
  waiting for room logs it rather than warning.
- `ReaderPost.tags` is optional. Core Data can't tell a post without tags
  from one whose tags it doesn't have, so it sends `nil` for none.
- The store takes the notification center it observes, so parallel tests
  don't sync each other's stores.
Once the server has sent a page saved by URL, the export wrote the server's ID for it, which the API
can't save it by. The import then sent it as a post and the server refused it with "Post not found".
The export now writes such a page without IDs, and the import saves any entry with no site or feed
by its URL, so files exported before this fix import too.
Saved opened every post by its IDs, so the post screen fetched it first: an error offline, and a
spinner of a few seconds online. The old Saved stream passed the stored post. Now a post Core Data
has with its content opens straight away, and others are still fetched.
A save made offline with the account at its 1,000-save cap waits on this device until there's room,
and nothing said so. The banner gives the number of such saves and says to remove some to make room.
The export stopped after 50 pages, assuming 40 posts a page, but the saved list sends 10. An
account at the 1,000-save cap exported only its newest 500 posts, with no sign that any were left
out. The cap is now 250 pages, which only stops a server that never ends the list.
@jkmassel

Copy link
Copy Markdown
Contributor Author

From Claude: Thanks for these.

  1. Fixed in 46665a9: a post that's stored on the device with its content opens from Saved straight away, including offline.
  2. Fixed in 2fc44cd: Saved shows a banner while saves wait for room under the cap.
  3. Left for a follow-up: Reader Saved: an imported page saved by URL doesn't send its title #26423.
  4. Upstream: Add ReaderSavedService to wp_mobile, with saved posts kept in the cache Automattic/wordpress-rs#1720.

The test plan in the description has the simulator checks for each fix.

@crazytonyli
crazytonyli added this pull request to the merge queue Nov 20, 2026
Merged via the queue into trunk with commit 986ae94 Nov 20, 2026
22 checks passed
@crazytonyli
crazytonyli deleted the jkmassel/reader-saved-posts-account branch November 20, 2026 05:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants